package pl.grabar.clinic.core.domain.visit;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnore;

import pl.grabar.clinic.core.domain.person.Doctor;
import pl.grabar.clinic.core.domain.person.Patient;
import pl.grabar.clinic.core.domain.visit.data.Disease;
import pl.grabar.clinic.core.domain.visit.data.HealthExamination;
import pl.grabar.clinic.core.domain.visit.data.MedicalPrescription;

/**
 * Klasa reprezentuje wizyte pacjenta u lekarza
 * 
 * @author db
 * 
 */
@Entity
@Table(name = "VISIT")
public class Visit implements Serializable {

	private static final long serialVersionUID = 1117537304345529563L;

	@Id
	@GeneratedValue
	@JsonIgnore
	private long id;

	@Column(name = "VISIT_DATE")
	private Date visitDate;

	@OneToOne(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH })
	@JoinColumn(name = "DOCTOR_ID")
	private Doctor doctor;

//	@JsonIgnore
	@OneToOne(fetch = FetchType.LAZY, cascade = { CascadeType.REMOVE, CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH })
	@JoinColumn(name = "PATIENT_ID")
	private Patient patient;

	/**
	 * Choroba
	 */
	@OneToOne(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH })
	@JoinColumn(name = "DISEASE_ID")
	private Disease disease;

	/**
	 * Badanie lekarskie
	 */
	@OneToOne(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH })
	@JoinColumn(name = "HEALTH_EXAMINATION_ID")
	private HealthExamination healthExamination;

	/**
	 * Recepta
	 */
	@OneToOne(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH })
	@JoinColumn(name = "MEDICAL_PRESCIPTION_ID")
	private MedicalPrescription medicalPrescription;
	
	/**
	 * Czy wizyta jest archiwalna - czyli w centrali
	 */
	@JsonIgnore
	private Boolean isArchived = false;
	
	/**
	 * Czy wizyta jest w trakcie realizacji.
	 */
	@JsonIgnore
	private Boolean isActive = true;

	/* AKCESORY */

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public Date getVisitDate() {
		return visitDate;
	}

	public void setVisitDate(Date visitDate) {
		this.visitDate = visitDate;
	}

	public Doctor getDoctor() {
		return doctor;
	}

	public void setDoctor(Doctor doctor) {
		this.doctor = doctor;
	}

	public Patient getPatient() {
		return patient;
	}

	public void setPatient(Patient patient) {
		this.patient = patient;
	}

	public Disease getDisease() {
		return disease;
	}

	public void setDisease(Disease disease) {
		this.disease = disease;
	}

	public HealthExamination getHealthExamination() {
		return healthExamination;
	}

	public void setHealthExamination(HealthExamination healthExamination) {
		this.healthExamination = healthExamination;
	}

	public MedicalPrescription getMedicalPrescription() {
		return medicalPrescription;
	}

	public void setMedicalPrescription(MedicalPrescription medicalPrescription) {
		this.medicalPrescription = medicalPrescription;
	}

	public Boolean getIsArchived() {
		return isArchived;
	}

	public void setIsArchived(Boolean isArchived) {
		this.isArchived = isArchived;
	}

	public Boolean getIsActive() {
		return isActive;
	}

	public void setIsActive(Boolean isActive) {
		this.isActive = isActive;
	}

}
